﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BlogBobby
{
    public class PostDTO
    {
        public int PostID { get; set; }
        public string Author { get; set; }
        public string Title { get; set; }
        public DateTime Date { get; set; }
        public string Body { get; set; }
        public List<CommentDTO> PostComments { get; set; }

        public static PostDTO GetFromPost(Post post)
        {
            PostDTO result = new PostDTO();
            result.Author = post.Author;
            result.Body = post.Body;
            result.Date = post.Date;
            result.PostID = post.PostID;
            result.Title = post.Title;
            result.PostComments = new List<CommentDTO>();
            foreach (var item in post.Comments)
            {
                CommentDTO temp = CommentDTO.CreateFromComment(item);
                result.PostComments.Add(temp);
            }
            return result;
        }
    }
}